package threading;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-06-26
 * Time: 11:59
 */
public class ThreadTest1 {
   volatile public static int flag = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
           while(flag == 0) {
               //不写任何东西
           }
            System.out.println("while循环结束,t1结束");
        });

        Thread t2 = new Thread(()->{
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入一个整数：");
            flag = sc.nextInt();
        });
        t1.start();
        t2.start();
    }
}
